package regist

import (
	"net"
	"sync"
	"time"
)

type ServerItem struct {
	TimeOut   int
	Add       string    //服务地址`
	StartTime time.Time //服务名称`
	Con       net.Conn
}
type GloabRegist struct {
	Sers map[string]ServerItem
	Lock sync.Mutex
}

func (g *GloabRegist) Init() {
	g.Sers = map[string]ServerItem{}
}

func (g *GloabRegist) Regist(name string, ser ServerItem) {
	defer g.Lock.Unlock()
	g.Lock.Lock()
	g.Sers[name] = ser
}
func (g *GloabRegist) GetSer(name string) ServerItem {
	defer g.Lock.Unlock()
	g.Lock.Lock()
	return g.Sers[name]
}
func (g *GloabRegist) GetAll() map[string]ServerItem {
	g.Lock.Lock()
	defer g.Lock.Unlock()
	return g.Sers
}
